package com.jiutong.meipenggang.ui.activitys;

import android.os.Bundle;
import android.text.InputType;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jiutong.meipenggang.R;
import com.jiutong.meipenggang.base.AppManager;
import com.jiutong.meipenggang.base.BaseActivity;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class OldPwdActivity extends BaseActivity {


    @Bind(R.id.rl_common_title_back)
    RelativeLayout rlCommonTitleBack;
    @Bind(R.id.tv_common_title)
    TextView tvCommonTitle;
    @Bind(R.id.et_change_pwd_old)
    EditText etChangePwdOld;
    @Bind(R.id.iv_change_pwd_hide_show)
    ImageView ivChangePwdHideShow;
    @Bind(R.id.btn_change_pwd_next)
    Button btnChangePwdNext;

    private boolean isShow = true;
    private String pwd = "123456";

    @Override
    public int getLayoutResouceId() {
        return R.layout.activity_old_pwd;
    }

    @Override
    protected void initView() {
        super.initView();
        tvCommonTitle.setText("安全验证");
    }


    @OnClick({R.id.rl_common_title_back, R.id.iv_change_pwd_hide_show, R.id.btn_change_pwd_next})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.rl_common_title_back:
                AppManager.getAppManager().finishActivity(this);
                break;
            case R.id.iv_change_pwd_hide_show:
                if(isShow){
                    etChangePwdOld.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
                    ivChangePwdHideShow.setBackgroundResource(R.mipmap.eye_open);
                    isShow = false;
                }else{
                    etChangePwdOld.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
                    ivChangePwdHideShow.setBackgroundResource(R.mipmap.eye_close);
                    isShow = true;
                }
                break;
            case R.id.btn_change_pwd_next:
                if(TextUtils.isEmpty(etChangePwdOld.getText().toString().trim())){
                    toastShortShow("请输入原登录密码");
                }else if(!pwd.equals(etChangePwdOld.getText().toString().trim())){
                    toastShortShow("密码错误");
                }else{
                    openActivity(ReSetPwdActivity.class);
                }
                break;
        }
    }
}
